
#include "BasicParameter.h"
#include "Common/Errors.h"

using namespace ttg_internal::utils;

//----------------------
//--- BasicParameter ---
//----------------------

BasicParameter::BasicParameter(const char *name, const char *type)
{
	if (UtilManagerDll::getRef()->createRootParameter == NULL)
		throw ttg::Error(ttg::Error::FATAL, "BasicParameter", "BasicParameter",
						 "Services was not inited (DllLoader is requred)");
	ID = UtilManagerDll::getRef()->createRootParameter(name, type);
	is_read_only = false;
}

BasicParameter::BasicParameter(const char *name, const char *type,  BasicParameterSet *owner)
{
	if (UtilManagerDll::getRef()->createParameter == NULL)
		throw ttg::Error(ttg::Error::FATAL, "BasicParameter", "BasicParameter",
						 "Services was not inited (DllLoader is requred)");
	ID = UtilManagerDll::getRef()->createParameter(name, type, owner->ID);
	is_read_only = false;
}

std::string BasicParameter::get()
{
	char *value = UtilManagerDll::getRef()->getParameterValue(ID);
	std::string res = value;
	UtilManagerDll::getRef()->releaseString(value);
	return res;
}
